//
//  HttpUtil.h
//  GasEasyPay
//
//  Created by 张宁宁 on 16/11/23.
//  Copyright © 2016年 lirenkj. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "SynthesizeSingleton.h"

typedef NS_ENUM(NSInteger,NetWorkState){
    WIFI,
    WWAN,
    NONET,
};

typedef NS_ENUM(NSInteger,HttpMethods){
    GET,
    POST,
    PUT,
    DELETE,
};
typedef NS_ENUM(NSInteger,HttpResponse){
    ServerError,
    Timeout,
    JsonError,
    ErrorMsg,
};

@interface HttpUtil : NSObject
SYNTHESIZE_SINGLETON_FOR_HEADER(HttpUtil);


/**
 *  当前网络状态
 *
 *   WIFI,WWAN,NONET,  无线,流量,没网
 */

- (void) netWorkReachability:(void (^)(NetWorkState status))netWorkStatus;

/**
 *  网络请求的方法
 *
 *  @param methords   请求方法 GET POST PUT DELETE
 *  @param url        网络请求url
 *  @param parameters 请求参数
 *  @param isjsondic  请求参数是否是Json格式
 *  @param success    success 回调
 *  @param failure    failure 回调
 */

-(void)doRequest:(HttpMethods)methords urlString:(NSString*)url parameters:(id)parameters isJsonDic:(BOOL)isjsondic success:(void (^)( id json ))success
         failure:(void (^)( NSString *msg))failure;
/**
 * 上传图片
 * @param url        上传路径
 * @param parameters 上传参数
 * @param image      需要上传的图片
 * @param name       服务器对应的字段
 * @param fileName   文件名称
 * @param success    成功回调
 * @param failure    失败回调
 */
- (void)uploadFileWithUrlString:(NSString*)url parameters:(id)parameters image:(UIImage *)image name:(NSString *)name fileName:(NSString *)fileName success:(void(^)(NSDictionary *dic))success failure:(void(^)(NSString *msg))failure;

@end
